# -*- coding: utf-8 -*-
"""
Created on Wed Feb 20 14:03:17 2019

@author: Administrator
"""

#功能：slice() 函数实现切片对象，主要用在切片操作函数里的参数传递。返回一个切片对象。
#class slice(start, stop[, step]):
#start -- 起始位置
#stop -- 结束位置
#step -- 间距

import numpy as np
#a:3*17
a = np.array([[0,1,8,4,5,6,87,9,5,0,0,0,9,5,2,3,2],
              [0,1,23,4,5,6,87,9,5,123,23,65,9,5,2,3,2],
              [0,1,23,4,5,6,87,9,5,123,23,65,9,5,2,3,2]])
b = a[:,slice(0,20,2)] #至少要两行才可以使用
print(b.shape)
print(b.size)
print(type(b))
print(b)

#c:2*3*10
c = np.array([[[0,1,8,4,5,6,87,9,5,0],
               [0,1,23,4,5,6,87,9,5,123],
               [0,1,23,4,5,6,87,9,5,123]],
              [[0,0,0,0,0,0,0,0,0,0],
               [1,1,1,1,1,1,1,1,1,1,],
               [2,2,2,2,2,2,2,2,2,2,]]])
d = c[:,slice(0,20,2),0] #用了三个参数则至少三维
print(d)